import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/ShowRequest")
public class ShowRequest extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        String  name=req.getParameter("name");
        String age=req.getParameter("age");
        int a=Integer.parseInt(age);
        String result="";
        if(a>=18){
            result="成人";
        }else{
            result="儿童";
        }
        resp.getWriter().write("名字="+name+" 年龄="+age+" 是 ："+result);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        String  name=req.getParameter("name");
        String age=req.getParameter("age");
        resp.getWriter().write("名字="+name+" 年龄="+age);
    }
}
